package server

import "time"

type ClientIdleTimeout struct {
	client *Client
}

func (x *ClientIdleTimeout) OnTimeout() {
	x.client.onIdleTimeout()
}

func (x *ClientIdleTimeout) IsTimeout() bool {
	return x.client.lastActiveAt.Add(x.client.idleTimeout).Before(time.Now())
}

func NewClientIdleTimeout(client *Client) *ClientIdleTimeout {
	return &ClientIdleTimeout{client: client}
}
